/**
 * Menu Principal da Aplicacao
 *
 * @this {UIMenu}
 * @version
 */

function UIMenu() {

    /**
     * Variaveis
     */
    var _oMenu = null;

    /**
     * Inicializa o objeto da classe
     */
    this.init = function() {

        var items = [
            {
                text: "Arquivo",
                submenu: {
                    id: "filemenu",
                    itemdata: [
                    [{
                        text: "Novo projeto",
                        //helptext: "Ctrl + N",
                        onclick: {
                            fn: this.onClickCreateProject
                        }
                    //,
                    //keylistener: {
                    //    ctrl: true,
                    //    keys: 78
                    //}
                    },
                    {
                        text: "Abrir projeto",
                        //helptext: "Ctrl + O",
                        onclick: {
                            fn: this.onClickOpenProject
                        }
                    //,
                    //keylistener: {
                    //    ctrl: true,
                    //    keys: 79
                    //}
                    },
                    {
                        text: "Fechar projeto",
                        //helptext: "",
                        onclick: {
                            fn: this.onClickCloseProject
                        }
                    //,
                    //keylistener: {
                    //    ctrl: true,
                    //    keys: 83
                    //}
                    }],
                    [{
                        text: "Salvar",
                        //helptext: "Ctrl + S",
                        onclick: {
                            fn: this.onClickSaveProject
                        }
                    //,
                    //keylistener: {
                    //    ctrl: true,
                    //    keys: 83
                    //}
                    },
                    {
                        text: "Salvar como...",
                        //helptext: "Ctrl + S",
                        onclick: {
                            fn: this.onClickSaveAsProject
                        }
                    //,
                    //keylistener: {
                    //    ctrl: true,
                    //    keys: 83
                    //}
                    }],
                    [{
                        text: "Imprimir layout",
                        //helptext: "Ctrl + P",
                        onclick: {
                            fn: this.onClickPrintLayout
                        }
                    //,
                    //keylistener: {
                    //    ctrl: true,
                    //    keys: 80
                    //}
                    }]

                    ]
                }

            },
            {
                text: "Configuracoes",
                submenu: {
                    id: "configmenu",
                    itemdata: [
                    [{
                        text: "Preferencias",
                        onclick: {
                            fn: this.onClickPreferences
                        }
                    }]

                    ]
                }
            },
            {
                text: "Ajuda",
                submenu: {
                    id: "helpmenu",
                    itemdata: [
                    [{
                        text: "Manual de Usuario",
                        onclick: {
                            fn: this.onClickUserManual
                        }
                    }]

                    ]
                }
            }
        ];

        _oMenu = new YAHOO.widget.MenuBar("menubar", {
            autosubmenudisplay: true,
            lazyload: true,
            itemdata: items
        });
        _oMenu.render();

    }

    /**
     * Funcoes
     */
    this.onClickCreateProject = function () {
        UIInstance.getUICreateProjectDialogInstance().showCreateProjectDialog();
    }

    this.onClickOpenProject = function () {
        UIInstance.getUIOpenProjectDialogInstance().showOpenProjectDialog();
    }

    this.onClickCloseProject = function () {
        UIInstance.getUICloseProjectDialogInstance().showCloseProjectDialog();
    }

    this.onClickSaveProject = function () {
        UIInstance.getUISaveProjectDialogInstance().showSaveProjectDiv();
    }

    this.onClickSaveAsProject = function () {
        UIInstance.getUISaveProjectDialogInstance().showSaveAsProjectDiv();
    }

    this.onClickPrintLayout = function () {
        UIInstance.getUIPrintLayoutDialogInstance().showPrintLayoutDialog();
    }

    this.onClickPreferences = function () {
        UIInstance.getUIPreferencesDialogInstance().showPreferencesDialog();
    }

    this.onClickFont = function () {
        UIInstance.getUIFontDialogInstance().showFontDialog();
    }

    this.onClickUserManual = function () {
        window.open(EGeneralTypes.eURLUserManual, "Manual de Usuario", "scrollbars=NO");
    }

    /**
     * Chamada do inicializador da classe
     */
    this.init();
}

